
import java.rmi.RMISecurityManager;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;

/**
 *
 * @author ernesta
 */
public class Client {
    public static void main(String[] args) {
        ServerInterface server;
        String host = "localhost";
        int port = 44444;
        
        if (args.length > 0) host = args[0];
        if (args.length > 1) port = Integer.parseInt(args[1]);
        
        System.out.println("Versi client: starting..." );
        System.out.println("Using registry at host " + host + " and port " + port);
        
        if (System.getSecurityManager() == null) {
            System.setSecurityManager(new RMISecurityManager());
        }
        
        try {
            Registry registry = LocateRegistry.getRegistry(host, port);
            server = (ServerInterface)registry.lookup("server");
            
            System.out.println(server.getAuthor("test.php"));
            server.testDB("test.php", "tukas");
        } catch (Exception ex) {
            System.out.println(ex);
        }
        
        //System.exit(0);
    }
}
